package com.testfileupload.uploadimg.design.observe;

import java.lang.reflect.Array;
import java.util.ArrayList;

public class Hanfeizi implements IHanfeizi, Observable {
    private ArrayList<Observer> observers = new ArrayList<>();
//    //是否在吃饭
//    private boolean isHavingBreakfast = false;
//    //是否在娱乐、
//    private boolean isHavingfun = false;
//
//    public boolean isHavingBreakfast() {
//        return isHavingBreakfast;
//    }
//
//    public void setHavingBreakfast(boolean havingBreakfast) {
//        isHavingBreakfast = havingBreakfast;
//    }
//
//    public boolean isHavingfun() {
//        return isHavingfun;
//    }
//
//    public void setHavingfun(boolean havingfun) {
//        isHavingfun = havingfun;
//    }

    @Override
    public void haveBreakfast() {
        System.out.println("正在吃饭");
//        this.isHavingBreakfast = true;
        this.notifyObservers("韩非子在吃饭");
    }

    @Override
    public void haveFun() {
        System.out.println("正在玩耍");
        this.notifyObservers("韩非子正在娱乐");
//        this.isHavingfun = true;
    }

    @Override
    public void addObserver(Observer observer) {
        this.observers.add(observer);
    }

    @Override
    public void deleteObserver(Observer observer) {
        this.observers.remove(observer);
    }

    @Override
    public void notifyObservers(String context) {
        for (Observer observer : observers) {
            observer.update(context);
        }
    }
}
